﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace MySerialization
{
    public class pList : ArrayList
    {
        IDS ds = new DS_NET_Client();

        public void Create(Person person)
        {
            ds.Create(person);
        }

        public void Read()
        {
            this.Clear();
            this.AddRange(ds.Read());
        }

        public void Update(int id, string fname, string lname, int age)
        {
            ds.Update(id, fname, lname, age);
        }

        public void Delete(int id)
        {
            ds.Delete(id);
        }

        public bool compare(pList init)
        {
            bool ret = false;
                        
            if (this.Count == init.Count)
            {
                if (this.Count == 0)
                {
                    ret = true;
                }
                else
                {
                    for (int i = 0; i < this.Count; i++)
                    {
                        if (!(ret = (this[i] as Person).compare((init[i] as Person))))
                        {
                            ret = false;
                            break;
                        }
                    }
                }
            }

            return ret;
        }
    }
}
